<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php $this->load->view('head'); ?>
	<script>
		$(document).ready(function() {
			// Handler for .ready() called.
			if($(update).val()==1){
				$str = "Your information is missing.\nPlease fill all data to begin request a job.";
				if($(address).val()=='')
					$str += "\n- Billing address";
				if($(phone).val()=='')
					$str += "\n- Mobile telephone";
				alert($str);
			}
		});
	</script>
</head>

<body>
	<?php
	if ($user->id > 0) {
		$this->load->view('header_logged.php');
	} else {
		$this->load->view('header_guest.php');
	}
	?>
	
	<!-- Content Area -->
	<div class="wrapper-world content">
		<div class="wrapper">			
			<h1><?php if ($user->id > 0) { ?>Profile <?php } else { ?>Sign up<?php } ?></h1>
			
			<div class="left-half">
				<?php echo form_open('create-an-account', array('class' => 'standard-form')); ?>
					<div class="one<?php if ($regErrors['name']) echo " warning"; ?>">
						<?php if ($regErrors['name']): ?><div class="warning-message">This field is mandatory.</div><?php endif; ?>
						<?php echo form_label('Full name', 'name'); ?>
						<?php $nameInput = array('name' => 'name', 'id' => 'name'); ?>
						<?php
							if ($this->input->post('name')) {
								$nameInput['value'] = $this->input->post('name');
							} elseif ($isEdit) {
								$nameInput['value'] = $userinfo->name;
							}
						?>
						<div class="type-text"><?php echo form_input($nameInput); ?></div>
						<div class="clr"></div>
					</div>
					<?php if (!$isEdit): ?>
					<div class="one<?php if ($regErrors['email'] || $regErrors['emailtaken']) echo " warning"; ?>">
						<?php if ($regErrors['email']): ?><div class="warning-message">Please enter valid e-mail address.</div><?php endif; ?>
						<?php if ($regErrors['emailtaken']): ?><div class="warning-message">Someone is already registered with this e-mail address.</div><?php endif; ?>
						<?php echo form_label('E-mail', 'email'); ?>
						<?php $emailInput = array('name' => 'email', 'id' => 'email'); ?>
						<?php
							if ($this->input->post('email')) {
								$emailInput['value'] = $this->input->post('email');
							} elseif ($isEdit) {
								$emailInput['value'] = $userinfo->username;
							}
						?>
						<div class="type-text"><?php echo form_input($emailInput); ?></div>
						<div class="clr"></div>
					</div>
					<?php else: ?>
					<div class="one">
						<?php echo form_label('E-mail', 'email'); ?>
						<?php $emailInput = array('name' => 'email', 'id' => 'email', 'disabled' => 'disabled'); ?>
						<?php
							$emailInput['value'] = $userinfo->username;
						?>
						<div class="type-text"><?php echo form_input($emailInput); ?></div>
						<div class="clr"></div>
					</div>
					<?php endif; ?>
					<div class="one<?php if ($regErrors['password'] || $regErrors['passwords']) echo " warning"; ?>">
						<?php if ($regErrors['password']): ?><div class="warning-message">This field is mandatory.</div>
						<?php elseif ($regErrors['passwords']): ?><div class="warning-message">Both passwords should match.</div><?php endif; ?>
						<?php echo form_label('Password', 'password'); ?>
						<div class="type-text"><?php echo form_password(array('name' => 'password', 'id' => 'password')); ?></div>
						<div class="clr"></div>
					</div>
                            
					<div class="one<?php if ($regErrors['passwords']) echo " warning"; ?>">
						<?php echo form_label('Confirm password', 'chpassword'); ?>
						<div class="type-text"><?php echo form_password(array('name' => 'chpassword', 'id' => 'chpassword')); ?></div>
						<div class="clr"></div>
					</div>
                            
                                        <div class="one">
						<?php echo form_label('Company name', 'company_name'); ?>
                                            
                                            <?php 
                                            $companyName = array('name' => 'company_name', 'id' => 'company_name', 'value' => '');
                                            
                                            if(@$userinfo->company_name) {
                                                $companyName['value'] = $userinfo->company_name;
                                            }
                                            
                                            if($this->input->post('company_name')) {
                                                $companyName['value'] = $this->input->post('company_name');
                                            }
                                            ?>
                                            
						<div class="type-text"><?php echo form_input($companyName); ?></div>
						<div class="clr"></div>
					</div>
                            
					<div class="one<?php if ($regErrors['address']) echo " warning"; ?>">
						<?php if ($regErrors['address']): ?><div class="warning-message">This field is mandatory.</div><?php endif; ?>
						<?php echo form_label('Billing address', 'address'); ?>
						<?php $addrInput = array('name' => 'address', 'id' => 'address'); ?>
						<?php
							if ($this->input->post('address')) {
								$addrInput['value'] = $this->input->post('address');
							} elseif ($isEdit) {
								$addrInput['value'] = $userinfo->address;
							}
						?>
						<div class="type-textarea"><?php echo form_textarea($addrInput); ?></div>
						<div class="clr"></div>
					</div>
					<div class="one<?php if ($regErrors['phone']) echo " warning"; ?>">
						<?php if ($regErrors['phone']): ?><div class="warning-message">Please enter valid mobile phone number.</div><?php endif; ?>
						<?php echo form_label('Mobile telephone', 'phone'); ?>
						<?php $phoneInput = array('name' => 'phone', 'id' => 'phone'); ?>
						<?php
							if ($this->input->post('phone')) {
								$phoneInput['value'] = $this->input->post('phone');
							} elseif ($isEdit) {
								$phoneInput['value'] = $userinfo->phone;
							}
						?>
						<div class="type-text"><?php echo form_input($phoneInput); ?></div>
						<div class="clr"></div>
					</div>
					<div class="one no-left">
						<div class="type-btn"><?php echo form_submit('doregister', 'Submit'); ?></div>
						<div class="clr"></div>
					</div>
				</form>
			</div>
			
			<div class="clr"></div>
		</div>
	</div> <!-- end of wrapper-world and .content -->
	
	
	<div class="wrapper-world footer-top">
		<div class="wrapper"></div>	
	</div>
	
	<?php $this->load->view('footer'); ?>
</body>
</html>
